package MAD.Examples;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
/**
 * This class defines an activity such that there will be a button and a textview
 * when the button on this activity is clicked, the textview display a text. There's
 * already a "hello world" text printed when the activity is started but we will 
 * change it to a text we want
 * @author bori
 *
 */
public class Example1Activity extends Activity {
	TextView text; // global variable that will hold the textview defined in our xml
	Button button;//this holds the button we defined in our xml.
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		
		/*text holds the textview's view defined in our xml*/
		text = (TextView) findViewById(R.id.textview);
		button = (Button) findViewById(R.id.button);
		
		/*the next line determines what we want the button to
		 *to do when the user clicks on the button*/
		button.setOnClickListener(new View.OnClickListener(){
			
			/*************************************
			 * this is the method that takes care
			 *of what happens when the button is 
			 *clicked. It has to be implemented
			 *or else there will be errors
			 **********************************/
			public void onClick(View v) {
				
				/*the setText just changes the text
				 *from "hello world" to "hello jessica"*/
				text.setText("Hello Jessica!!");
			}

		});
	}
}